package com.wlf.html.service;

import java.util.List;

import org.apache.http.util.TextUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.wlf.html.dao.OrderDao;
import com.wlf.html.model.Order;
@Service
public class OrderServiceImpl implements OrderService {

	@Autowired
	OrderDao orderDao;
	
	@Override
	@Transactional
	public boolean insert(Order order) {
		// TODO Auto-generated method stub
		orderDao.insert(order);
		return true;
	}

	@Override
	@Transactional
	public int delete(String orderBH) {
		// TODO Auto-generated method stub
		return orderDao.delete(orderBH);
	}

	@Transactional
	public boolean update(Order order) {
		// TODO Auto-generated method stub
		return orderDao.update(order);
	}

	@Override
	@Transactional
	public List<Order> findAll() {
		// TODO Auto-generated method stub
		return orderDao.findAll();
	}

	@Override
	@Transactional
	public List<Order> search(String orderBH, String nameJD, String name, String phone, String category) {
		// TODO Auto-generated method stub
		if(orderBH != null && !TextUtils.isEmpty(orderBH)) {
			return orderDao.findByOrder(orderBH);
		}
		return orderDao.search(orderBH,nameJD,name,phone,category);
	}

	@Override
	@Transactional
	public List<Order> findByOrder(String orderBH) {
		// TODO Auto-generated method stub
		return orderDao.findByOrder(orderBH);
	}

}
